package com.whnk.web.controller.pm;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.pm.domain.CtrInfo;
import com.whnk.pm.domain.CtrWlInfo;
import com.whnk.pm.service.ICtrInfoService;
import com.whnk.pm.service.ICtrWlInfoService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 订单人月 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-07-15
 */
@Controller
@RequestMapping("/pm/ctrWlInfo")
public class CtrWlInfoController extends BaseController
{
    private String prefix = "pm/ctrWlInfo";
	
	@Autowired
	private ICtrWlInfoService ctrWlInfoService;
	
	@Autowired
	private ICtrInfoService ctrInfoService;
	
	@RequiresPermissions("pm:ctrWlInfo:view")
	@GetMapping()
	public String ctrWlInfo()
	{
	    return prefix + "/ctrWlInfo";
	}
	
	/**
	 * 查询订单人月列表
	 */
	@RequiresPermissions("pm:ctrWlInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(CtrWlInfo ctrWlInfo)
	{
		startPage();
        List<CtrWlInfo> list = ctrWlInfoService.selectCtrWlInfoList(ctrWlInfo);
		return getDataTable(list);
	}
	
	/**
	 * 新增订单人月
	 */
	@GetMapping("/add/{ctrId}")
	public String add(@PathVariable("ctrId") Integer ctrId, ModelMap mmap)
	{
		CtrInfo ctrInfo = ctrInfoService.selectCtrInfoById(ctrId);
		mmap.put("ctrInfo", ctrInfo);
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存订单人月
	 */
	@RequiresPermissions("pm:ctrWlInfo:add")
	@Log(title = "订单人月", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(CtrWlInfo ctrWlInfo)
	{		
		return toAjax(ctrWlInfoService.insertCtrWlInfo(ctrWlInfo));
	}

	/**
	 * 修改订单人月
	 */
	@GetMapping("/edit/{wlId}")
	public String edit(@PathVariable("wlId") Integer wlId, ModelMap mmap)
	{
		CtrWlInfo ctrWlInfo = ctrWlInfoService.selectCtrWlInfoById(wlId);
		mmap.put("ctrWlInfo", ctrWlInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存订单人月
	 */
	@RequiresPermissions("pm:ctrWlInfo:edit")
	@Log(title = "订单人月", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(CtrWlInfo ctrWlInfo)
	{		
		return toAjax(ctrWlInfoService.updateCtrWlInfo(ctrWlInfo));
	}
	
	/**
	 * 删除订单人月
	 */
	@RequiresPermissions("pm:ctrWlInfo:remove")
	@Log(title = "订单人月", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(ctrWlInfoService.deleteCtrWlInfoByIds(ids));
	}
	
}
